#!/bin/bash
if [ "$(id -u)" != "0" ]; then
  echo -e "需要用root用户运行此脚本\n"
  exit 1
fi
echo -e "\n"
echo  "开始替换Pi-Star_Binaries_sbin"
cd /usr/local/sbin
git remote rm origin
git remote add origin https://gitee.com/four_quarter/Pi-Star_Binaries_sbin.git
git remote -v
echo -e "\n"
mmdvmHostVer=`MMDVMHost -v | awk '{print $3}' | cut -c 1-8`
if [ ${mmdvmHostVer} \> 20181131 ]; then
  echo  "开始替换Pi-Star_v4_Binaries_Bin"
  cd /usr/local/bin
  git remote rm origin
  git remote add origin https://gitee.com/four_quarter/Pi-Star_v4_Binaries_Bin.git
  git remote -v
  echo -e "\n"
else
  echo  "开始替换Pi-Star_Binaries"
  cd /usr/local/bin
  git remote rm origin
  git remote add origin https://gitee.com/four_quarter/Pi-Star_Binaries.git
  git remote -v
  echo -e "\n"
fi

echo "开始替换Pi-Star_DV_Dash"
cd /var/www/dashboard
git remote rm origin
git remote add origin https://gitee.com/four_quarter/Pi-Star_DV_Dash.git
git remote -v
echo -e "\n"
echo -e "替换完成，手动执行 \033[34m sudo pistar-daily.cron\033[0m 进行更新"
echo -e "\n"
